fix: read piped access token from stdin instead of prompting @W-22954140@#1526
Merged
Conversation
…140@ When an access token is piped to 'sf org login access-token' and an auth file already exists for that user, the command triggered an interactive overwrite confirm against an already-consumed stdin, crashing with 'User force closed the prompt with 13 null' (Node exit 13). Read the token directly from stdin when it is not a TTY, and skip the overwrite confirm in that non-interactive case. A timeout guards against a stdin stream that never sends data or EOF. Fixes #3573
Contributor
Author
|
verified as well: ➜ dreamhouse-lwc git:(main) ✗ hub:(DevHub) scratch:(ccresorts) ➜ echo $(pbpaste) | sf org login access-token --instance-url https://ccresortscom-f-dev-ed.develop.my.salesforce.com
✔ Access token of user to use for authentication
? A file already exists for user "willie@ccresorts.com", which is associated with the access token you provided.
Are you sure you want to overwrite the existing file? (y/N)
Error (13): User force closed the prompt with 13 null
➜ dreamhouse-lwc git:(main) ✗ hub:(DevHub) scratch:(ccresorts) ➜ echo $(pbpaste) | ../../oss/plugin-auth/bin/run.js org login access-token --instance-url https://ccresortscom-f-dev-ed.develop.my.salesforce.com
Successfully authorized willie@ccresorts.com with org ID 00Dg7000007C0t6EAC |
soridalac
approved these changes
Jul 20, 2026
Contributor
|
QA notes: ✅: Pipe token + existing auth file: successfully authorized |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sf org login access-tokencrashed withError (13): User force closed the prompt with 13 nullwhen an access token was piped via stdin and an auth file already existed for that user. The command consumed stdin for the token prompt, then fired a second interactive "overwrite existing file?"confirmprompt against an already-exhausted stdin, which inquirer rejects → unresolved top-level await → Node exit 13. Empty/EOF stdin hit the same crash.confirm(treat it like--no-prompt, since there's no way to answer it).--no-prompt, andSF_ACCESS_TOKEN/SFDX_ACCESS_TOKENenv-var paths are unchanged.Fixes forcedotcom/cli#3573
Work Item
@W-22954140@: sf auth accesstoken store failing with "User force closed the prompt with 13 null"
Regression window
The stdin token reader was rewritten in #902 ("feat: use new inquirer") to use an interactive
@inquirer/passwordprompt. Piping a token then hitting a second@inquirer/confirmprompt against a non-TTY/exhausted stdin is what produces the exit-13 crash. Reported as working in 2.136.8, broken from the next release.Proof of Work
Verified against a local build (
bin/run.js):Error (13)Successfully authorized(exit 0)true | sf ...)Error (13)SF_ACCESS_TOKEN+--no-prompttsc): cleaneslint src/...): cleanValidation
Two independent adversarial cold reviews (diff-only, no implementation context) were run. Findings addressed:
readPipedStdinpath (not just the env-var short-circuit)Test plan
echo "<orgId>!<token>" | sf org login access-token --instance-url <url>succeeds when an auth file already exists (no prompt, no exit 13)sf org login access-token --instance-url <url>in a real terminal still prompts for the token and for overwriteSF_ACCESS_TOKEN=<token> sf org login access-token --instance-url <url> --no-promptstill works